package br.indt.framework.ui.common;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * Basic dimensions used by Displayable widgets.
 *  
 * @author Nokia Institute of Technology
 *
 */
public abstract class Drawable 
{
	private String name = null;
	protected int width = 0;
	protected int height = 0;
	protected int leftMargin = 0;
	protected int topMargin = 0;
	protected int rightMargin = 0;
	protected int bottomMargin = 0;
	protected Image backgroundImage = null;
	protected Image backgroundImageLeft = null;
	protected Image backgroundImageMiddle = null;
	protected Image backgroundImageRight = null;
	protected int backgroundColor = -1;
	protected boolean pressedDown = false;	
	protected boolean down = true;

	public boolean isPressedDown()
	{
		return pressedDown;
	}

	public boolean isDown()
	{
		return down;
	}

	public void setDown(boolean down)
	{
		this.down = down;
	}

	public Drawable(String name) 
	{
		this.name = name;
	}
		
	public String getName() 
	{
		return name;
	}

	public void setMargin(int left, int top, int right, int bottom)
	{
		leftMargin = left;
		topMargin = top;
		rightMargin = right;
		bottomMargin = bottom;
	}

	public void setWidth(int width) 
	{
		this.width = width;
	}
	
	public int getWidth() 
	{
		return width;
	}
	
	public void setHeight(int height)
	{
		this.height = height;
	}
	
	public int getHeight() 
	{
		return height;
	}
	
	public int getLeftMargin() 
	{
		return leftMargin;
	}
	
	public int getRightMargin() 
	{
		return rightMargin;
	}
	
	public int getTopMargin() 
	{
		return topMargin;
	}

	public void setTopMargin(int pTopMargin) 
	{
		topMargin = pTopMargin;
	}

	public int getBottomMargin() 
	{
		return bottomMargin;
	}
	
	public void setBottomMargin(int pBottomMargin) 
	{
		bottomMargin = pBottomMargin;
	}
	
	public void setBackgroundImage(Image image) 
	{
		this.backgroundImage = image;
	}
	
	public Image getBackgroundImage() {
		return backgroundImage;
	}
	
	public void setBackgroundImages(Image imageLeft, Image imageMiddle, Image imageRight)
	{
		this.backgroundImageLeft = imageLeft;
		this.backgroundImageMiddle = imageMiddle;
		this.backgroundImageRight = imageRight;
	}
	
	public void setBackgroundColor(int color) 
	{
		this.backgroundColor = color;
	}
	
	public int getBackgroundColor() 
	{
		return this.backgroundColor;
	}

	protected abstract void paint(Graphics g, int x, int y, int maxWidth, int maxHeight);
	
	public void setPressedDownState(boolean pressedDown) 
	{
		this.pressedDown = pressedDown;
	}
	
	public boolean animate() 
	{
		return false;
	}
}